package br.org.etec.dotcao.mailer;

import java.io.IOException;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;

public class LogBuilder {
	
	public static Logger successLogger(Class<?> type) throws IOException{
		Logger logger = Logger.getLogger(type);
		
		BasicConfigurator.configure();
		
		logger.setLevel(Level.ALL);
		
		RollingFileAppender appender = new RollingFileAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN), "success.log", true);
		appender.setMaxFileSize("10MB");
		
		logger.addAppender(appender);
		
		return logger;
	}

	public static Logger errorLogger(Class<?> type) throws IOException{
		Logger logger = Logger.getLogger(type);
		
		BasicConfigurator.configure();
		
		logger.setLevel(Level.WARN);
		
		RollingFileAppender appender = new RollingFileAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN), "error.log", true);
		appender.setMaxFileSize("10MB");
		
		logger.addAppender(appender);
		
		return logger;
	}
	

}
